package com.bilibili.service.impl;

import com.bilibili.entity.PicCartoon;
import com.bilibili.entity.PicCategory;
import com.bilibili.entity.PicRegion;
import com.bilibili.exception.BusinessException;
import com.bilibili.mapper.PicCartoonMapper;
import com.bilibili.mapper.PicCategoryMapper;
import com.bilibili.mapper.PicRegionMapper;
import com.bilibili.service.PicUploadService;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Objects;

import static com.bilibili.constant.BusinessConstant.CARTOON_MAX_CATEGORY;
import static com.bilibili.constant.BusinessConstant.CARTOON_MAX_REGION;

@Service
public class PicUploadServiceImpl implements PicUploadService {

    @Autowired
    private PicCategoryMapper picCategoryMapper;

    @Autowired
    private PicRegionMapper picRegionMapper;

    @Autowired
    private PicCartoonMapper picCartoonMapper;

    @Override
    public List<PicCategory> getAllCategory() {
        PicCategory category = picCategoryMapper.getCategoryByName("漫画");
        //拿到漫画的id作为父亲的id
        Integer parentId = category.getId();
        //作为该父亲的id,找到所有与漫画相关的category
        return picCategoryMapper.getAllCategoryByParentId(parentId);
    }

    @Override
    public List<PicRegion> getAllRegion() {
        return picRegionMapper.getAllRegion();
    }



}
